package com.samuel.igoodman.interceptor;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
import com.samuel.igoodman.entity.account.Userinfo;

@SuppressWarnings("serial")
public class PermissionInterceptor implements Interceptor {

	public void destroy() {
		
	}

	public void init() {
		
	}

	public String intercept(ActionInvocation invocation) throws Exception {
	
		
		Userinfo userinfo = (Userinfo) ServletActionContext.getRequest().getSession().getAttribute(Userinfo.SESSION_PARAMETER_NAME);
		if(null!=userinfo){
			return invocation.invoke();
		}
		invocation.getInvocationContext().getValueStack().setValue("message", "抱歉 ，您还没有登录，请先登录。  :( ");
		//TODO  加上返回的地址
//		invocation.getInvocationContext().getValueStack().setValue("namespace", namespace);
//		invocation.getInvocationContext().getValueStack().setValue("actionName", actionName);
		return "login";
	}

}
